/**
  ******************************************************************************
  * @file    xxx.c 
  * @author  SD Electronics xxx
  * @version V1.0
  * @date    xx-xx-xx
  * @brief   xxxxxxxxxxxxxxxxxx.
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "sd_common.h"

/** 
  * @brief  tm1621c nop宏定义  
  */
#define nop __NOP()

/** 
  * @brief  tm1621c 硬件配置相关结构体 
  */ 
#define TM1621C_CS_INIT   do{ \
        pmu_set_port_mux(GPIO_PORT_A,GPIO_BIT_7,PMU_PORT_MUX_GPIO);    \
        pmu_set_pin_dir(GPIO_PORT_A,BIT(7), GPIO_DIR_OUT);     \
        pmu_set_pin_pull(GPIO_PORT_A, BIT(7), true);    \
        pmu_set_pin_to_PMU(GPIO_PORT_A,BIT(7));     \
    } while(0)

#define TM1621C_CS_H    pmu_set_gpio_value(GPIO_PORT_A, BIT(7), 1)
#define TM1621C_CS_L    pmu_set_gpio_value(GPIO_PORT_A, BIT(7), 0)

#define TM1621C_WR_INIT   do{ \
        pmu_set_port_mux(GPIO_PORT_C, GPIO_BIT_5, PMU_PORT_MUX_GPIO);    \
        pmu_set_pin_dir(GPIO_PORT_C,BIT(5), GPIO_DIR_OUT);     \
        pmu_set_pin_pull(GPIO_PORT_C, BIT(5), true);    \
        pmu_set_pin_to_PMU(GPIO_PORT_C,BIT(5));     \
    } while(0)

#define TM1621C_WR_H    pmu_set_gpio_value(GPIO_PORT_C, BIT(5), 1)
#define TM1621C_WR_L    pmu_set_gpio_value(GPIO_PORT_C, BIT(5), 0)

#define TM1621C_DATA_INIT   do{ \
        pmu_set_port_mux(GPIO_PORT_C,GPIO_BIT_6,PMU_PORT_MUX_GPIO);    \
        pmu_set_pin_dir(GPIO_PORT_C,BIT(6), GPIO_DIR_OUT);     \
        pmu_set_pin_pull(GPIO_PORT_C, BIT(6), true);    \
        pmu_set_pin_to_PMU(GPIO_PORT_C,BIT(6));     \
    } while(0)

#define TM1621C_DATA_H    pmu_set_gpio_value(GPIO_PORT_C, BIT(6), 1)
#define TM1621C_DATA_L    pmu_set_gpio_value(GPIO_PORT_C, BIT(6), 0)
/**
  * @}
  */

/** 
  * @brief  tm1621c 字码
  */
//0111---0COM3COM2COM1
//初始化
uint8_t Smg0[10] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};  //0
uint8_t Smg2[7] = {0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};  //0
uint8_t Smg1 = 0x70;  //0~F字型码

/** 
  * @brief  Battery--addr0
  */ 
uint8_t BatteryIcon[4] = 
{
   0x04,//NULL
   0x14,//1格
   0x15,//2格
   0x1F,//3格
};

/** 
  * @brief  CNT--addr3
  */
#define BAT_Icon_addr 0x00
#define CNT_Icon_addr 0x03
#define TIME_Icon_addr 0x04
#define CAL_Icon_addr 14
#define CDN_Icon_addr 17
#define COLON_Icon_addr 13
#define COMMA_Icon_addr 16
#define ICON_DISPLAY 0x01

uint8_t TIME_Icon = 0x01;

/** 
  * @brief  Number--addr1
  */ 
uint8_t Num0[10][2] = 
{
    #if 0
    {0x60, 0x65},//0~9
    {0x00, 0x60},
    {0x20, 0x47},
    {0x00, 0x6F},
    {0x40, 0x62},
    {0x40, 0x2F},
    {0x60, 0x2F},
    {0x00, 0x64},
    {0x60, 0x6F},
    {0x40, 0x6F},
    #else
    {0x56, 0x06},
    {0x00, 0x06},
    {0x72, 0x04},
    {0xF0, 0x06},
    {0x24, 0x06},
    {0xF4, 0x02},
    {0xF6, 0x02},
    {0x40, 0x06},
    {0xF6, 0x06},
    {0xF4, 0x06},
    #endif
};

/** 
  * @brief  Number--addr4
  */ 
uint8_t Num1_0[10] = 
{
    0x56,
    0x00,
    0x72,
    0xF0,
    0x24,
    0xF4,
    0xF6,
    0x40,
    0xF6,
    0xF4,
};

/** 
  * @brief  Number--addr12
  */ 
uint8_t Num1_1[10] = 
{
    0x60,
    0x60,
    0x40,
    0x60,
    0x60,
    0x20,
    0x20,
    0x60,
    0x60,
    0x60,
};

/** 
  * @brief  Number--addr 13
  */ 
uint8_t Num2[10][2] = 
{
    {0x60, 0x65},//0~9
    {0x00, 0x60},
    {0x20, 0x47},
    {0x00, 0x6F},
    {0x40, 0x62},
    {0x40, 0x2F},
    {0x60, 0x2F},
    {0x00, 0x64},
    {0x60, 0x6F},
    {0x40, 0x6F},
};

/** 
  * @brief  Number--addr 17
  */ 
uint8_t Num3[10][2] = 
{
    {0x56, 0x06},
    {0x00, 0x06},
    {0x72, 0x04},
    {0xF0, 0x06},
    {0x24, 0x06},
    {0xF4, 0x02},
    {0xF6, 0x02},
    {0x40, 0x06},
    {0xF6, 0x06},
    {0xF4, 0x06},
};

/** 
  * @brief  Number
  */ 
uint8_t Number[20] = 
{
    0x0F, //addr 0
    0x0F, 
    0x0F, 
    0x0F, 
    0x0F, 
    0x0F, //addr 5
    //以下地址无效
    0x00,
    0x00, 
    0x00, 
    0x00, 
    0x00, 
    0x00, 
    0x00,
    //以上地址无效
    0x0F, //addr 13
    0x0F, 
    0x0F, 
    0x0F, 
    0x0F, 
    0x0F, 
    0x0F, //addr 19
};

/** 
  * @brief  tm1621c 清屏 
  */ 
uint8_t Tab0[25] = 
{
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00
};
   


/** 
  * @brief  tm1621c 硬件配置相关结构体 
  */ 
ST_TM1621C_PHY g_sttm1621cPhyParam;


/** 
  * @brief tm1621c 控制结构体 
  */ 
ST_TM1621C_CTRL g_sttm1621cCtrl = 
{                       
    false,
    &g_sttm1621cPhyParam,
};


/** 
  * @brief  tm1621c 延时函数  
  */
void delay_nms(uint32_t n)   
{
	co_delay_100us(10*n);
}   


/**
  * @brief  Write_Data_H
  * @note   从高位写入数据
  * @param  None
  * @retval None
  */
void Write_Data_H(uint8_t Data, uint8_t Cnt)       //Data的高cnt位写入TM1621，高位在前   
{   
    uint8_t i;   
    for(i = 0; i < Cnt; i ++)   
    {   
		TM1621C_WR_L;   
		if(Data & 0x80)                          //从最高位发送   
			TM1621C_DATA_H;        
		else    
			TM1621C_DATA_L;   
		nop;   
		nop;   
		TM1621C_WR_H;   
		Data <<= 1;   
    }   
    TM1621C_WR_L;   
    TM1621C_DATA_L;   
}   


/**
  * @brief  Write_Data_L
  * @note   从低位写入数据
  * @param  None
  * @retval None
  */
void Write_Data_L(uint8_t Data,uint8_t Cnt)        //Data 的低cnt位写入TM1621，低位在前    
{    
    unsigned char i;    
    for(i = 0; i < Cnt; i ++)    
    {    
        TM1621C_WR_L;   
        if(Data & 0x01)                           //从低位发送   
            TM1621C_DATA_H;     
        else    
            TM1621C_DATA_L;    
        nop;   
        nop;   
        TM1621C_WR_H;   
        Data >>= 1;   
    }    
    TM1621C_WR_L;   
    TM1621C_DATA_L;   
}    
   

/**
  * @brief  WriteCmd
  * @note   写入控制命令
  * @param  None
  * @retval None
  */
void WriteCmd(uint8_t Cmd)   
{
    TM1621C_CS_L;
    nop;
    Write_Data_H(0x80, 4);     //写入命令标志100   
    Write_Data_H(Cmd, 8);      //写入命令数据   
    TM1621C_CS_H;
    nop;
}   


/**
  * @brief  WriteOneData
  * @note   指定地址写入数据，实际写入后4位
  * @param  None
  * @retval None
  */
void WriteOneData(uint8_t Addr, uint8_t Data)   
{   
    TM1621C_CS_L;
    nop;  
    Write_Data_H(0xa0, 3);     //写入数据标志101   
    Write_Data_H(Addr << 2, 6);  //写入地址数据(A5-A4-A3-A2-A1-A0)从高位开始写数据   
    Write_Data_L(Data, 4);     //写入数据   
    TM1621C_CS_H;
    nop;   
}   

/**
  * @brief  WriteAllData
  * @note   连续写入方式，每次数据为8位，写入数据
  * @param  None
  * @retval None
  */
void WriteAllData(uint8_t Addr, uint8_t *p, uint8_t cnt)   
{   
    uint8_t i;
    TM1621C_CS_L;
    nop;  
    Write_Data_H(0xa0, 3);      //写入数据标志101   
    Write_Data_H(Addr << 2, 6);   //写入地址数据   
    for(i = 0; i < cnt; i++)      //写入数据   
    {   
        Write_Data_L(*p, 8);         
        p ++;   
    }   
    TM1621C_CS_H;   
    nop;   
}

/**
  * @brief  SDInittm1621c
  * @note   xxx
  * @param  None
  * @retval None
  */
void SDInittm1621c(PST_TM1621C_PHY psttm1621cCntPhy)
{
    //GPIO初始化
    //CS--PA7
    //Write--PC5
    //DATA--PC6
    TM1621C_CS_INIT;
    TM1621C_WR_INIT;
    TM1621C_DATA_INIT;

    TM1621C_CS_H;
    TM1621C_WR_H;
    TM1621C_DATA_H;
    nop;
	
    delay_nms(1);             
    WriteCmd(BIAS);         //1/3偏压 4公共口   
    WriteCmd(RC);           //内部RC振荡   
    WriteCmd(SYSDIS);       //关系统振荡器和LCD偏压发生器   
    WriteCmd(WDTDIS);       //禁止看门狗   
    WriteCmd(SYSEN);        //打开系统振荡器   
    WriteCmd(LCDON);        //开LCD偏压
    WriteAllData(0, Tab0, 25);   //LCD不显示   
    //printf("usr: sd tm1621c init.\r\n");

	#if 0 //以下测试代码
    
	delay_nms(1);  
	//上电测试
    for(int i = 0; i < 10; i ++)
    {
        if(i < 4)
            WriteAllData(0, &BatteryIcon[i], 1);
        Num0[i][0] = Num0[i][0] | 0x01;          
        WriteAllData(1, &Num0[i][0], 2);
        WriteAllData(17, &Num3[i][0], 2);
        WriteAllData(13, &Num2[i][0], 2);
        WriteAllData(12, &Num1_1[i], 1);
        WriteAllData(4, &Num1_0[i], 1);
        delay_nms(1000); 
    }
	#endif
}

/**
  * @brief  tm1621c_getCNT
  * @note   xxx
  * @param  None
  * @retval None
  */
void tm1621c_getCNT(uint32_t displaydata, uint8_t* NUM_Uint_Show, uint8_t* NUM_Ten_Show, uint8_t* NUM_Hund_Show, uint8_t* NUM_Thou_Show)
{
    *NUM_Thou_Show = displaydata/1000%10;	//千
    *NUM_Hund_Show = displaydata/100%10;	 //百
    *NUM_Ten_Show  = displaydata/10%10;	    //十
    *NUM_Uint_Show = displaydata/1%10;	    //个
}

/**
  * @brief  tm1621c_getTime
  * @note   xxx
  * @param  None
  * @retval None
  */
void tm1621c_getTime(uint32_t displaydata, uint8_t* Min_Show_Ten, uint8_t* Min_Show_Uint, uint8_t* Second_Show_Ten, uint8_t* Second_Show_Uint)
{
    uint8_t show_min, show_sec;
    show_min = displaydata / 60;
	show_sec = displaydata % 60;
	//Min
	*Min_Show_Ten = show_min / 10 % 10;
	*Min_Show_Uint = show_min / 1 % 10;
	//S
	*Second_Show_Ten = show_sec / 10 % 10;
	*Second_Show_Uint = show_sec / 1 % 10;
}

/**
  * @brief  tm1621c_getCAL
  * @note   xxx
  * @param  None
  * @retval None
  */
void tm1621c_getCAL(uint32_t displaydata, uint8_t* CAL_Hund_Show, uint8_t* CAL_Ten_Show, uint8_t* CAL_Uint_Show, uint8_t* CAL_Deci_Show)
{
    *CAL_Hund_Show = displaydata/1000%10;	    //百位
    *CAL_Ten_Show = displaydata/100%10;	        //十位
    *CAL_Uint_Show  = displaydata/10%10;	    //个位
    *CAL_Deci_Show = displaydata/1%10;	        //小数点位
}

/**
  * @brief  tm1621cOpen
  * @note   xxx
  * @param  None
  * @retval None
  */
static long tm1621cOpen(void *pvHandle, unsigned long ulOption)
{
    PST_DEV_MANAGE pstDevManage = pvHandle;

    long lRet = EN_DEV_CTL_RET_CODE_FAILED;
    if (0 != pstDevManage)
    {
        PST_TM1621C_CTRL psttm1621cCtrl = (PST_TM1621C_CTRL)pstDevManage->pvData;
        if(false == psttm1621cCtrl->bInitFlag)
        {
			/* tm1621c初始化 */
            SDInittm1621c(psttm1621cCtrl->psttm1621cInfo);
            psttm1621cCtrl->bInitFlag = true;
        }
        lRet = EN_DEV_CTL_RET_CODE_SUCCESSED;
    }
    return lRet;
}  

/**
  * @brief  tm1621cRead
  * @note   xxx
  * @param  None
  * @retval None
  */
static long tm1621cRead(void *pvHandle, unsigned long ulOpertion, unsigned char *pucDataBuf, int* ulDataSize)
{
    PST_DEV_MANAGE pstDevManage = pvHandle;
    long lRet = EN_DEV_CTL_RET_CODE_FAILED;
    if (0 != pstDevManage)
    {
        PST_TM1621C_CTRL psttm1621cCtrl = (PST_TM1621C_CTRL)pstDevManage->pvData;
        //
        if(true == psttm1621cCtrl->bInitFlag)
        {
            ;
        }
        lRet = EN_DEV_CTL_RET_CODE_SUCCESSED;
    }
    return lRet;    
}

/**
  * @brief  tm1621cWrite
  * @note   xxx
  * @param  None
  * @retval None
  */
static long tm1621cWrite(void *pvHandle, unsigned long ulOpertion, unsigned char *pucDataBuf, unsigned long ulDataLen)
{
    PST_DEV_MANAGE pstDevManage = pvHandle;
    long lRet = EN_DEV_CTL_RET_CODE_FAILED;
    if (0 != pstDevManage)
    {
        PST_TM1621C_CTRL psttm1621cCtrl = (PST_TM1621C_CTRL)pstDevManage->pvData;
        //
        if(true == psttm1621cCtrl->bInitFlag)
        {
            //写入电池电量
            psttm1621cCtrl->psttm1621cInfo->Icon_Battery = ulOpertion;
        }
        lRet = EN_DEV_CTL_RET_CODE_SUCCESSED;
    }
    return lRet;
}

/**
  * @brief  tm1621cControl
  * @note   xxx
  * @param  None
  * @retval None
  */
static long tm1621cControl (void *pvHandle,unsigned long ulOpertion, unsigned long ulControlCmd, void *pvd)
{
    PST_DEV_MANAGE pstDevManage = pvHandle;
    long lRet = EN_DEV_CTL_RET_CODE_FAILED;
    if (0 != pstDevManage)
    { 
        PST_TM1621C_CTRL psttm1621cCtrl = (PST_TM1621C_CTRL)pstDevManage->pvData;

        if(true == psttm1621cCtrl->bInitFlag)
        {
            switch(ulOpertion)
            {
                case EN_DISP_MODE_CNT:
                {
                    uint8_t NUM_Thou_Show, NUM_Hund_Show, NUM_Ten_Show, NUM_Uint_Show;
                    //printf("[EN_DISP_MODE_CNT]\r\n");
                    WriteAllData(0, Tab0, 15);                                                  //LCD不显示   
                    WriteOneData(BAT_Icon_addr, psttm1621cCtrl->psttm1621cInfo->Icon_Battery);  //显示电量
                    WriteOneData(CNT_Icon_addr, 0x01);                                          //显示CNT
                    
                    //取出--------------------------个、--------------十、-------------百、-----------千
                    tm1621c_getCNT(ulControlCmd, &NUM_Uint_Show, &NUM_Ten_Show, &NUM_Hund_Show, &NUM_Thou_Show);
                    //0-9显示个位
                    Num3[NUM_Uint_Show][0] = Num3[NUM_Uint_Show][0] & 0xFE;
                    WriteAllData(17, &Num3[NUM_Uint_Show][0], 2);

                    //>0-9显示十位
                    if(ulControlCmd > 9)
                    {
                        Num2[NUM_Ten_Show][0] = Num2[NUM_Ten_Show][0] & 0xEE;
                        Num2[NUM_Ten_Show][1] = Num2[NUM_Ten_Show][1] & 0xEF;
                        WriteAllData(13, &Num2[NUM_Ten_Show][0], 2);                                
                    }

                    //>0-99显示百位
                    if(ulControlCmd > 99)
                    {
                        Num1_0[NUM_Hund_Show] = Num1_0[NUM_Hund_Show] & 0xFE;
                        Num1_1[NUM_Hund_Show] = Num1_1[NUM_Hund_Show] & 0xE0;
                        WriteAllData(4, &Num1_0[NUM_Hund_Show], 1);
                        WriteAllData(12, &Num1_1[NUM_Hund_Show], 1);                                
                    }
                    //>0-999显示千位
                    if(ulControlCmd > 999)
                    {
                        Num0[NUM_Thou_Show][0] = Num0[NUM_Thou_Show][0];
                        Num0[NUM_Thou_Show][1] = Num0[NUM_Thou_Show][1] | 0x01;
				        WriteAllData(1, &Num0[NUM_Thou_Show][0], 2);
                        WriteAllData(4, &Num1_0[NUM_Hund_Show], 1);
                    }
                    break;
                }
                case EN_DISP_MODE_TIME:
                {
                    uint8_t Min_Show_Ten, Min_Show_Uint, Second_Show_Ten, Second_Show_Uint;
                    //printf("[EN_DISP_MODE_TIME]\r\n");
                    tm1621c_getTime(ulControlCmd, &Min_Show_Ten, &Min_Show_Uint, &Second_Show_Ten, &Second_Show_Uint);

                    //显示图标
                    WriteOneData(BAT_Icon_addr, psttm1621cCtrl->psttm1621cInfo->Icon_Battery);  //显示电量
                    WriteOneData(CNT_Icon_addr, 0x00); //清除CNT
                    WriteOneData(TIME_Icon_addr, 0x01);//显示Time

                    //显示秒的个位 
                    Num3[Second_Show_Uint][0] = Num3[Second_Show_Uint][0] & 0xFE;
                    WriteAllData(17, &Num3[Second_Show_Uint][0], 2);

                     //显示秒的十位
                    Num2[Second_Show_Ten][0] = Num2[Second_Show_Ten][0] & 0xEF;
                    Num2[Second_Show_Ten][1] = Num2[Second_Show_Ten][1] & 0xEF;
                    WriteAllData(13, &Num2[Second_Show_Ten][0], 2);

                     //显示分的个位
                    Num1_0[Min_Show_Uint] = Num1_0[Min_Show_Uint] | 0x01;
                    Num1_1[Min_Show_Uint] = Num1_1[Min_Show_Uint] | 0x10;
                    WriteAllData(4, &Num1_0[Min_Show_Uint], 1);
                    WriteAllData(12, &Num1_1[Min_Show_Uint], 1);

                     //显示分的十位
                    Num0[Min_Show_Ten][0] = Num0[Min_Show_Ten][0];
                    Num0[Min_Show_Ten][1] = Num0[Min_Show_Ten][1] & 0xFE;
                    WriteAllData(1, &Num0[Min_Show_Ten][0], 2);
                    WriteAllData(4, &Num1_0[Min_Show_Uint], 1);
                    break;
                }
                case EN_DISP_MODE_CAL:
                {
                    //printf("[EN_DISP_MODE_CAL]\r\n");
                    uint8_t CAL_Hund_Show, CAL_Ten_Show, CAL_Uint_Show, CAL_Deci_Show;
                    tm1621c_getCAL(ulControlCmd, &CAL_Hund_Show, &CAL_Ten_Show, &CAL_Uint_Show, &CAL_Deci_Show);
                    
                    WriteAllData(1, Tab0, 5);   //LCD不显示   
                    WriteOneData(BAT_Icon_addr, psttm1621cCtrl->psttm1621cInfo->Icon_Battery);  //显示电量
                    
                    WriteOneData(CAL_Icon_addr, 0x01);//显示Cal
                    WriteOneData(COMMA_Icon_addr, 0x01);//显示逗号

                    //显示小数点位和个位--卡路里
                    Num2[CAL_Uint_Show][0] = Num2[CAL_Uint_Show][0] & 0xF0 | 0x10;
                    Num2[CAL_Uint_Show][1] = Num2[CAL_Uint_Show][1] | 0x10;
                    WriteAllData(13, &Num2[CAL_Uint_Show][0], 2);

                    Num3[CAL_Deci_Show][0] = Num3[CAL_Deci_Show][0] & 0xFE;
                    WriteAllData(17, &Num3[CAL_Deci_Show][0], 2);

                    //>0-99显示十位--卡路里
                    if(ulControlCmd > 99)
                    {
                        Num1_0[CAL_Ten_Show] = Num1_0[CAL_Ten_Show] & 0xFE;
                        Num1_1[CAL_Ten_Show] = Num1_1[CAL_Ten_Show] & 0xE0;
                        WriteAllData(4, &Num1_0[CAL_Ten_Show], 1);
                        WriteAllData(12, &Num1_1[CAL_Ten_Show], 1);                                
                    }
                    //显示百位
                    if(ulControlCmd > 999)
                    {
                        Num0[CAL_Hund_Show][0] = Num0[CAL_Hund_Show][0];
                        Num0[CAL_Hund_Show][1] = Num0[CAL_Hund_Show][1] & 0xFE;
				        WriteAllData(1, &Num0[CAL_Hund_Show][0], 2);
                        WriteAllData(4, &Num1_0[CAL_Ten_Show], 1);
                    }
                    break;
                }

                case EN_DISP_MODE_CDN:
                //printf("[EN_DISP_MODE_CDN]\r\n");
                //WriteAllData(0, Tab0, 25);   //LCD不显示   
                WriteOneData(BAT_Icon_addr, psttm1621cCtrl->psttm1621cInfo->Icon_Battery);  //显示电量
                Num0[ulControlCmd][0] = Num0[ulControlCmd][0] | (psttm1621cCtrl->psttm1621cInfo->Icon_Battery);
                WriteAllData(1, &Num0[ulControlCmd][0], 2);

                Num3[ulControlCmd][0] = Num3[ulControlCmd][0] | 0x01;
                WriteAllData(17, &Num3[ulControlCmd][0], 2);

                Num2[ulControlCmd][0] = Num2[ulControlCmd][0] & 0xEE;
                Num2[ulControlCmd][1] = Num2[ulControlCmd][1] & 0xEF;
                WriteAllData(13, &Num2[ulControlCmd][0], 2);

                Num1_1[ulControlCmd] = Num1_1[ulControlCmd] | 0x10;
                WriteAllData(12, &Num1_1[ulControlCmd], 1);

                Num1_0[ulControlCmd] = Num1_0[ulControlCmd] &0xFE;
                WriteAllData(4, &Num1_0[ulControlCmd], 1);
                break;

                case EN_DISP_MODE_NULL:
                //printf("[EN_DISP_MODE_CDN]\r\n");
                WriteAllData(0, Tab0, 25);   //LCD不显示   
                break;
                default:
                break;
            }
            ;
        }
        lRet = EN_DEV_CTL_RET_CODE_SUCCESSED;
    }
    return lRet;             
}

/**
  * @brief  tm1621cClose
  * @note   xxx
  * @param  None
  * @retval None
  */
static long tm1621cClose (void *pvHandle)
{
    PST_DEV_MANAGE pstDevManage = pvHandle;
    long lRet = EN_DEV_CTL_RET_CODE_FAILED;
    if (0 != pstDevManage)
    {
        lRet = EN_DEV_CTL_RET_CODE_SUCCESSED;
    }
    return lRet;     
}



/**
  * @brief  g_sttm1621cCtlFUN
  * @note  xxx
  * @param  None
  * @retval None
  */
ST_CTR_FUN g_sttm1621cCtlFUN = 
{
    tm1621cOpen,		//打开
    tm1621cRead,		//读
    tm1621cWrite,		//写
    tm1621cControl,		//控制
    tm1621cClose    	//关闭
};


/******************* (C) COPYRIGHT 2011 ShenZhenShiding electronics **************************/
